Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: only index votes for specified chain_num #59

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

paul121
Copy link
Contributor

@paul121 paul121 commented Feb 13, 2024

Closes #44

Comment on lines +42 to +50
cur.execute(
"SELECT MAX(block_height) FROM votes WHERE chain_num = %s", (_chain_num,)
)
res = cur.fetchone()
max_block_height = 0 if res[0] is None else res[0]
logger.debug(f"{_chain_num=} {max_block_height=}")
for event in new_events_to_process(
cur, "votes", _chain_num, max_block_height
):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the only lines I'm really changing in the PR, the rest are only un-indented from removing the for loop.

This catches the edge case when there are no votes in the table and MAX(block_height) == null, so default to 0.

@paul121 paul121 requested a review from blushi February 13, 2024 15:46
Copy link
Member

@blushi blushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@blushi blushi merged commit e580612 into main Mar 4, 2024
1 check passed
@blushi blushi deleted the paul/chore-votes-logic branch March 4, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify logic in index votes process
2 participants